.TH std::thread 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::thread \- std::thread

.SH Synopsis
   Defined in header <thread>
   class thread;               \fI(since C++11)\fP

   The class thread represents a single thread of execution. Threads allow multiple
   functions to execute concurrently.

   Threads begin execution immediately upon construction of the associated thread
   object (pending any OS scheduling delays), starting at the top-level function
   provided as a constructor argument. The return value of the top-level function is
   ignored and if it terminates by throwing an exception, std::terminate is called. The
   top-level function may communicate its return value or an exception to the caller
   via std::promise or by modifying shared variables (which may require
   synchronization, see std::mutex and std::atomic).

   std::thread objects may also be in the state that does not represent any thread
   (after default construction, move from, detach, or join), and a thread of execution
   may not be associated with any thread objects (after detach).

   No two std::thread objects may represent the same thread of execution; std::thread
   is not CopyConstructible or CopyAssignable, although it is MoveConstructible and
   MoveAssignable.

.SH Member types

   Member type                    Definition
   native_handle_type (optional*) implementation-defined

.SH Member classes

   id represents the id of a thread
      \fI(public member class)\fP

.SH Member functions

   constructor          constructs new thread object
                        \fI(public member function)\fP
                        destructs the thread object, underlying thread must be joined
   destructor           or detached
                        \fI(public member function)\fP
   operator=            moves the thread object
                        \fI(public member function)\fP
.SH Observers
                        checks whether the thread is joinable, i.e. potentially running
   joinable             in parallel context
                        \fI(public member function)\fP
   get_id               returns the id of the thread
                        \fI(public member function)\fP
   native_handle        returns the underlying implementation-defined thread handle
                        \fI(public member function)\fP
   hardware_concurrency returns the number of concurrent threads supported by the
   \fB[static]\fP             implementation
                        \fI(public static member function)\fP
.SH Operations
   join                 waits for the thread to finish its execution
                        \fI(public member function)\fP
                        permits the thread to execute independently from the thread
   detach               handle
                        \fI(public member function)\fP
   swap                 swaps two thread objects
                        \fI(public member function)\fP

.SH Non-member functions

   std::swap(std::thread) specializes the std::swap algorithm
   \fI(C++11)\fP                \fI(function)\fP

.SH See also

   jthread std::thread with support for auto-joining and cancellation
   (C++20) \fI(class)\fP
